package com.jdd.modules.mqtt.server.revice;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Map;

/**
 * @program: jdd-people-passage
 * @ClassName ReciveMqttContext
 * @description: 获取mqtt消息处理策略上下文对象
 * @author: zsj
 * @create: 2022-03-24 10:08
 * @Version 1.0
 **/
@Component
public class ReciveMqttStrategyContext {
    @Autowired
    private Map<String, IReciveMqttBaseStrategy> reciveMqttBaseStrategyMap;

    public IReciveMqttBaseStrategy getStrategy(String key) {
        IReciveMqttBaseStrategy reciveMqttBaseStrategy = reciveMqttBaseStrategyMap.get(key);
        if (null == reciveMqttBaseStrategy) {
            throw new IllegalArgumentException("未找到" + key + "类型的消息处理方法");
        }
        return reciveMqttBaseStrategy;
    }
}